/**
 * Copyright (c) 2018-2022, NXOS Development Team
 * SPDX-License-Identifier: Apache-2.0
 * 
 * Contains: Memory Manage Unite 
 * 
 * Change Logs:
 * Date           Author            Notes
 * 2021-10-20     JasonHu           Init
 * 2022-1-20      JasonHu           add map & unmap
 */

#ifndef __ARCH_MMU__
#define __ARCH_MMU__

#include <nxos_mini.h>

#include <arch/mm.h>
#include <arch/pgtable_hwdef.h>
#include <arch/pgtable_prot.h>
#include <arch/pgtable_types.h>
#include <arch/pgtable.h>

#define NX_PAGE_ATTR_READ     (0)
#define NX_PAGE_ATTR_WRITE    (PTE_WRITE)
#define NX_PAGE_ATTR_EXEC     (PTE_PXN & ~PTE_PXN) /* make sure no exec */

#define NX_PAGE_ATTR_RWX    (NX_PAGE_ATTR_READ | NX_PAGE_ATTR_WRITE | NX_PAGE_ATTR_EXEC)

#define NX_PAGE_ATTR_KERNEL_RO PAGE_KERNEL_RO
#define NX_PAGE_ATTR_KERNEL_ROX PAGE_KERNEL_ROX

#define NX_PAGE_ATTR_KERNEL PAGE_KERNEL_EXEC
#define NX_PAGE_ATTR_USER   ((PAGE_KERNEL_EXEC & ~PTE_UXN) | PTE_USER)

#endif  /* __ARCH_MMU__ */
